﻿namespace Snipps.Controls
{
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;

    public class BusyTextBox : TextBox
    {
        public static readonly DependencyProperty IsSearchingProperty = DependencyProperty.Register(
            "IsSearching", typeof(bool), typeof(BusyTextBox), new PropertyMetadata(default(bool)));

        public static readonly DependencyProperty WatermarkBrushProperty = DependencyProperty.Register(
            "WatermarkBrush", typeof(Brush), typeof(BusyTextBox), new PropertyMetadata(Brushes.Gray));

        public static readonly DependencyProperty WatermarkTextProperty = DependencyProperty.Register(
            "WatermarkText", typeof(string), typeof(BusyTextBox), new PropertyMetadata(default(string)));

        static BusyTextBox()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(BusyTextBox), new FrameworkPropertyMetadata(typeof(BusyTextBox)));
        }

        public bool IsSearching
        {
            get
            {
                return (bool)GetValue(IsSearchingProperty);
            }

            set
            {
                SetValue(IsSearchingProperty, value);
            }
        }

        public Brush WatermarkBrush
        {
            get
            {
                return (Brush)GetValue(WatermarkBrushProperty);
            }

            set
            {
                SetValue(WatermarkBrushProperty, value);
            }
        }

        public string WatermarkText
        {
            get
            {
                return (string)GetValue(WatermarkTextProperty);
            }

            set
            {
                SetValue(WatermarkTextProperty, value);
            }
        }
    }
}